/**
 * Copyright (C), 2015-2022, XXX有限公司
 * <p>
 * FileName: AuthContextHolder
 * <p>
 * Author: 12044
 * <p>
 * Date: 2022/1/19 15:06
 * <p>
 * Description:
 * <p>
 * History:
 *
 * <author> <time> <version> <desc>
 * <p>
 * 作者姓名 修改时间 版本号 描述
 */


package com.atguigu.yygh.common.utils;


import com.atguigu.yygh.common.helper.JwtHelper;

import javax.servlet.http.HttpServletRequest;

/**
 * 获取当前用户信息工具类<br>
 * 〈〉
 *
 * @author 12044

 * @create 2022/1/19

 * @since 1.0.0

 */

public class AuthContextHolder {
    //获取当前用户id
    public static Long getUserId(HttpServletRequest request) {
        //从header获取token
        String token = request.getHeader("token");
        //jwt从token获取userid
        Long userId = JwtHelper.getUserId(token);
        return userId;
    }

    //获取当前用户名称
    public static String getUserName(HttpServletRequest request) {
        //从header获取token
        String token = request.getHeader("token");
        //jwt从token获取userid
        String userName = JwtHelper.getUserName(token);
        return userName;
    }

}
